Skip to main content

All Questions

Tagged with
2votes
4answers
392views

How to combine multiple functions into a single template based function

Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
user146290's user avatar
10votes
4answers
2kviews

Is the inability to find code by searching for a class name a reason to avoid using auto in c++ variable declarations?

According to https://softwareengineering.stackexchange.com/a/180616/432039 suggested, I know the answer advised "auto" should be used instead of the actual type when declaring variables. ...
wcminipgasker2023's user avatar
1vote
3answers
625views

Is "avoid misuse in other languages" a valid reason to avoid myString=="abc" in c++?

For example, I know in c++, I can use myString=="abc" to check if 2 strings are equal. However, in Java, it is comparing if 2 objects are the same object. Also in other language, for ...
wcminipgasker2023's user avatar
4votes
5answers
2kviews

Alternatives to if-else on data reading

I have some code on Arduino (so, written in C++) that receives a String through the UART terminal, reads the String, then decides what String to print back and how many things to print depending on ...
HFOrangefish's user avatar
1vote
3answers
935views

Debug statements in production quality code?

Would anyone here recommend using debug statements such as the following in production quality code? I think these are personally one of the easiest to include or exclude, but they make the code hard ...
love4shells___'s user avatar
-5votes
1answer
1kviews

How do I manage multiple nested for-loops without using multiple variables?

If I have code that looks like this: int i; void functionA (){ for (i=0; i<10; i++){ functionB(); } } void functionB (){ for (i=0; i<20; i++){ doSomething(); } } ...
Noah Smith's user avatar
65votes
10answers
21kviews

I never use pointers in my C++ code. Am I coding C++ wrong? [closed]

This question may sound strange to you, but I am learning C++ all by myself. I have nobody whom I could ask for mentoring and I would be very glad for some advice. I have started recently to program ...
curiouscupcake's user avatar
5votes
1answer
6kviews

The case against path expressions in #include directives

I am preparing for a discussion with my fellow programmers which will be about their use of the C/C++ #include directive. The codebase which I have to retrofit to Automotive standards is using ...
Vroomfondel's user avatar
2votes
2answers
439views

Organization of C++ source code for reusable components

I'm implementing a custom templated container as part of a learning project in C++. The container makes use of different components like serialization, memory management, iterators. I am wondering ...
NBWL's user avatar
1vote
2answers
396views

const function parameters and default behavior

Say I have a C++ function /** * @param path If empty, the system default is used */ void foo(const std::string& path); And in my implementation I have a default handling for empty paths void ...
PhilLab's user avatar
7votes
8answers
882views

Relevance of optimization techniques

I've heard of some techniques to optimize code and make it faster: On one side are clearly relevant optimization: use of better algorithms, benchmarking, etc. On the other side are techniques with a ...
JayZ's user avatar
  • 827
0votes
1answer
551views

Public class members in PIMPL

I'm attempting to use the PIMPL idiom. This is my public header file in include/foo.h: class FooPrivate; class Foo { public: Foo(); ~Foo(); private: FooPrivate* p_impl; }; ...
Sevag's user avatar
3votes
4answers
3kviews

How to use Macros in Programming to make code faster, efficient and compact

Recently I was going through some of the source-codes of the best competitive programmers in the world. I found out that those people use a template while writing programs, preferably in C++. I have ...
strikersps's user avatar
2votes
2answers
298views

Introduce code standard into old code

Our main product is written in C++ MFC and follows the same code standard as MFC. Now we will start to develop new components, and think about whether we should continue to use the same outdated ...
magol's user avatar
10votes
1answer
13kviews

Is there any reason *not* to forward declare all forward declarable function parameter/return types?

I ran into a situation where my build speeds have started to become large and have affected productivity. I had already minimized header dependencies before using forward declarations. Now I've ...
Krupip's user avatar
  • 1,320

153050per page
close